﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Threshold.aspx.cs" Inherits="EnvironmentalMonitor.WebApplication.Environmental.Machine.Setup.Threshold" %>

<!DOCTYPE html>
<html>
<head runat="server">
    <title></title>
    <% = this.ReferencejQueryCss %>
    <% = this.ReferencejQueryJavascript %>
    <style type="text/css">
        html, body
        {
            margin: 0px;
            padding: 0px;
            height: 100%;
            overflow: hidden;
        }
        #dialog_form
        {
            margin: 0;
            padding: 10px 30px;
        }
        .form_title
        {
            font-size: 14px;
            font-weight: bold;
            color: #666;
            padding: 5px 0;
            margin-bottom: 10px;
            border-bottom: 1px solid #ccc;
        }
        .form_item
        {
            margin-bottom: 5px;
        }
        .form_item label
        {
            display: inline-block;
            width: 120px;
        }
        .form_input
        {
            width: 200px;
        }
    </style>
    <script type="text/javascript">
        var url = '<% = this.SaveJsonUrl %>';
        var detectorUrl = '<% = this.DetectorListJsonUrl %>';

        function editModule() {
            var row = $('#list_data_grid').datagrid('getSelected');
            if (row) {
                if (row.Ip) {
                    var currentUrl = detectorUrl + '?machineId=' + row.Guid;
                    $('#list_data_grid_dialog').dialog('open').dialog('setTitle', '修改');
                    $('#dialog_form').form('clear');
                    $('#dialog_form').form('load', row);
                    initEditModule();
                    $('#detector_list_data_grid').datagrid({
                        url: currentUrl
                    });
                }
                else {
                    alert('请先设置IP！');
                }
            }
        };

        function saveModule() {
            $('#dialog_form').form('submit', {
                url: url,
                onSubmit: function () {
                    var result = validateModule();
                    if (result) {
                        result = $(this).form('validate');
                    }
                    return result;
                },
                success: function (result) {
                    var result = eval('(' + result + ')');
                    $.messager.show({
                        title: '消息',
                        msg: result.msg
                    });
                    $('#list_data_grid_dialog').dialog('close');
                    $('#list_data_grid').datagrid('reload');
                }
            });
        };

        function initEditModule() {
        };

        function validateModule() {
            var result = true;

            return result;
        };
    </script>
</head>
<body>
    <div style="width: 100%; height: 100%">
        <table id="list_data_grid" title="<% = this.Description %>管理" class="easyui-datagrid"
            style="width: 100%; height: 100%" url="<% = this.ListJsonUrl %>" toolbar="#list_data_grid_toolbar"
            pagination="true" rownumbers="true" fitcolumns="true" singleselect="true" fit="true"
            pagelist="[<% = int.MaxValue %>]">
            <thead>
                <tr>
                    <th field="RoomName">
                        机房
                    </th>
                    <th field="Name">
                        名称
                    </th>
                </tr>
            </thead>
        </table>
        <div id="list_data_grid_toolbar">
            <a href="#" class="easyui-linkbutton" iconcls="icon-reload" plain="true" onclick="javascript:editModule()">
                修改<% = this.Description %></a>
        </div>
        <div id="list_data_grid_dialog" class="easyui-dialog" style="width: 640px; height: 360px;
            padding: 10px 20px" closed="true" buttons="#list_data_grid_dialog_buttons">
            <div class="form_title">
                <% = this.Description %>信息</div>
            <table id="detector_list_data_grid" title="" class="easyui-datagrid" style="width: 100%;
                height: 100%" pagination="true" rownumbers="false" fitcolumns="true" singleselect="true"
                fit="true" pagelist="[<% = int.MaxValue %>]">
                <thead>
                    <tr>
                        <th field="Serial">
                            序号
                        </th>
                        <th field="DetectorTypeName">
                            探头类型
                        </th>
                        <th field="DetectorTypeCode">
                            探头类型代码
                        </th>
                        <th field="DetectorTypeTypeText">
                            探头分类
                        </th>
                        <th field="DetectorTypeThreshold">
                            探头阀值
                        </th>
                        <th field="DetectorTypeMinimum">
                            探头最小值
                        </th>
                        <th field="DetectorTypeMaximum">
                            探头最大值
                        </th>
                    </tr>
                </thead>
            </table>
            <form id="dialog_form" enctype="multipart/form-data" method="post">
            <input type="hidden" name="Guid" />
            <input type="hidden" name="Ip" />
            </form>
        </div>
        <div id="list_data_grid_dialog_buttons">
            <a href="#" class="easyui-linkbutton" iconcls="icon-ok" onclick="javascript:saveModule()">
                保存</a> <a href="#" class="easyui-linkbutton" iconcls="icon-cancel" onclick="javascript:$('#list_data_grid_dialog').dialog('close')">
                    取消</a>
        </div>
    </div>
</body>
</html>
